require(['./config'], () => {
    require(['template', 'swiper', 'header', 'footer', 'util'], (template, Swiper) => {
        class Index {
            constructor() {
                // console.dir($)
                this.getActivities()
                this.getBlack()
                this.getServer()
                this.swiper()
            }
            // 根据自己写的json数据对热销模块的渲染
            getActivities() {
                $.get('/libs/json/Activities.json', resp => {
                    // console.log(resp)
                    var str = template('activitiesListTemplate', {
                        list: resp
                    })
                    // console.log(str)
                    $("#activitiesList").html(str)
                })
            }
            getBlack() {
                // 根据rap2的假数据渲染小黑家族模块
                $.get('http://rap2api.taobao.org/app/mock/233854/index/black_family', resp => {
                    // console.log(resp)
                    if (resp.code === 200) {
                        const { list } = resp.body
                        $('#blackList').html(template('blackListTemplate', { list }))
                    }
                })
            }

            getServer() {
                // 根据rap2的假数据渲染官方特别服务模块
                $.get('http://rap2api.taobao.org/app/mock/233854/index/server', resp => {
                    // console.log(resp)
                    if (resp.code === 200) {
                        const { list } = resp.body
                        $('#serverList').html(template('serverListTemplate', { list }))
                    }
                })
            }
            swiper() {
                var mySwiper = new Swiper('.banner', {
                    loop: true, // 循环模式选项
                    speed: 1000,
                    autoplay: true,
                    // 如果需要分页器
                    pagination: {
                        el: '.swiper-pagination',
                        clickable: true

                    },

                    // 如果需要前进后退按钮
                    navigation: {
                        nextEl: '.swiper-button-next',
                        prevEl: '.swiper-button-prev',
                    }
                })
            }
        }
        new Index()
    })
})